package com.sniper.clienthi.controller;

import com.sniper.clienthi.feign.ServiceDbaService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @author suzhen
 * @create 2018/3/16
 */
@RestController
public class ClientController {

    private static Logger logger = LoggerFactory.getLogger(ClientController.class);

    @Autowired
    private RestTemplate template;

    @Autowired
    private ServiceDbaService serviceDbaService;

    @Value("${server.port}")
    String port;

    @RequestMapping("/hi")
    public String home(@RequestParam String name) {
        logger.debug("hi :{}", name);
        System.out.println(name);
        return serviceDbaService.hi2(name);
    }


    @RequestMapping("/shop")
    public String shop(@RequestParam String name) {
        logger.debug("client-hi :{}", name);
        return "client-hi shop " + name + ",i am from port:" + port;
    }

}
